﻿using System;

interface A
{
    double area();
}

interface B
{
    void setColor(string c);
}

interface C : A, B
{
    void volume();
}

class Cylinder : C
{
    private double radius;
    private double height;
    private string color;

    public Cylinder(double radius, double height)
    {
        this.radius = radius;
        this.height = height;
        this.color = "未知";
    }

    public double area()
    {
        return 2 * Math.PI * radius * radius + 2 * Math.PI * radius * height;
    }

    public void setColor(string c)
    {
        color = c;
    }

    public void volume()
    {
        double vol = Math.PI * radius * radius * height;
        Console.WriteLine($"圆柱体体积: {vol:F2}");
    }

    public void displayInfo()
    {
        Console.WriteLine($"圆柱体信息:");
        Console.WriteLine($"半径: {radius:F2}");
        Console.WriteLine($"高度: {height:F2}");
        Console.WriteLine($"颜色: {color}");
        Console.WriteLine($"表面积: {area():F2}");
        volume();
    }
}

class Program
{
    static void Main(string[] args)
    {
        Cylinder cylinder = new Cylinder(3.0, 5.0);

        cylinder.setColor("红色");

        cylinder.displayInfo();

        Console.WriteLine("\n--- 创建另一个圆柱体 ---");

        Cylinder cylinder2 = new Cylinder(2.5, 8.0);
        cylinder2.setColor("蓝色");
        cylinder2.displayInfo();

        Console.WriteLine("\n--- 通过接口调用方法 ---");
        A aInterface = cylinder;
        Console.WriteLine($"通过接口A调用area(): {aInterface.area():F2}");

        B bInterface = cylinder;
        bInterface.setColor("绿色");

        C cInterface = cylinder;
        cInterface.volume();

        Console.ReadKey();
    }
}